/**
  * @class Character
  * Characters contain Body Part layers that can be controlled by that body part's
  * associated Null Layer.
  * @param {String} name The name of the Character
  * @param {Int} id The unique id of this Character
  * @param {CompItem} comp The composition to add this Character to.
  * @constructor
  */
 debug("Initializing - > Character()");
function Character(name, id, comp)
{
    /******************** PRIVATE VARIABLES ******************/

    var scriptName = "CR_Character.jsx";

    /**
     *The null layer associated with this Character
     */
    var nullLayer = null;

    /**
     *An array of the body parts that this Character contains
     */
    var bodyParts = new Array();

    /**
     *The comment in this Character's null layer
     */
    var comment = "Character: {name: " + name + ", id: " + id + "}";
    debug("-- Properties set");

    //Create this Character's nullLayer
    nullLayer = comp.layers.addNull();
    nullLayer.name = name;

    //Set this layer's comment to the Character Default
    nullLayer.comment = comment;

    debug("-- Null Layer Created");

    /******************** PRIVATE FUNCTIONS ***********************/


    /********************* PUBLIC METHODS ************************/

    return {
        /**
         *Get the id of this Character
         *
         *@return {Int} The id of this character
         */
        getId : function()
        {
            return id;
        },
        /**
         * Sets the comment for this Character Layer by either overwriting it or appending
         * to it.
         * @memberOf Character
         * @param {String} c The comment to be set as this layer's comment
         * @param {Bool} overwrite True to overwrite the comment. False to append the comment to the current comment.
         */
        setComment : function(c, overwrite)
        {
            if(overwrite == undefined)
            {
                overwrite = false;
            }

            if(overwrite)
            {
                nullLayer.comment = c;
            }else{
                nullLayer.comment = nullLayer.comment + "\n" + c
            }
        },

        /**
         * Returns the comment for this Character Layer
         * @memberOf Character
         * @return {String} The comment of this Character's null layer.
         */
        getComment : function()
        {
            return nullLayer.comment;
        },


        /**
         * Sets the name of this character's null layer.
         * @memberOf Character
         * @param {String} name The name to set as this Character's Layer name.
         */
        rename : function(n)
        {
            try
            {
                //Set this character's name
                name = n;

                //Change the name of this Character's null layer
                nullLayer.name = name;
            }catch(e){
                throw(new CR_Error(errors.COULDNT_RENAME_CHARACTER, e, $.stack, scriptName));
            }
        },

        /**
         * Returns the name of this Character
         * @memberOf Character
         * @returns {String} The name of this character
         */
        getName : function()
        {
            return name;
        },


        /**
         * Adds a body part to this Character
         * @memberOf Character
         * @param {BodyPart} bodyPart Body Part Object to be added to this character
         */
        addBodyPart : function(bodyPart)
        {

        },

        /**
         * Returns a BodyPart based upon the BodyPart's name.
         * @memberOf Character
         * @param {String} name The name of the body part to return.
         */
        getBodyPart : function(name)
        {

        },


        /**
         * Returns an array of BodyParts belonging to this Character
         * @memberOf Character
         * @returns {Array} An array of BodyParts belonging to this Character
         */
        getBodyParts : function()
        {
            return bodyParts;
        },


        /**
         * Toggles the solo switch for this Character and all of its body parts.
         * @memberOf Character
         */
        toggleSolo : function()
        {

        },


        /**
         * Toggles the visibility of this Character and all its body parts.
         * @memberOf Character
         */
        toggleVisibility : function()
        {

        },


        /**
         * Toggles the Character and all it's BodyParts shy status.
         * @memberOf Character
         */
        toggleShy : function()
        {

        },

        /**
         * Converts this Character to a human readable summary
         */
        toString : function()
        {
            return "Character: " + name + ", \
            id: " + id + ", \
            # Body Parts: " + bodyParts.length;
        }
    }
}